package user

import (
	"app/api/middleware"
	"app/internal/model/admin"
	"app/internal/pkg"
	"github.com/gin-gonic/gin"
	"net/http"
	"time"
)

// 实现用户查找
func FindUser(ctx *gin.Context) {
	var data admin.Payload
	err := ctx.ShouldBindJSON(&data)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to bind args:" + err.Error(),
		})
		return
	}
	//通过用户的keys去获取信息
	var reps []admin.User
	for i := 0; i < len(data.Keys); i++ {
		var rep admin.User
		rep.Id = data.Keys[i]
		rep.Head = ""
		reps = append(reps, rep)
	}
	//

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": reps,
	})
}

// 实现管理员登陆
func Login(ctx *gin.Context) {
	var data admin.AdminLoginRequest
	err := ctx.ShouldBindJSON(&data)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to bind args:" + err.Error(),
		})
		return
	}
	token, err := pkg.GenToken(data.Email, middleware.AdminUserExpireDuration, middleware.AdminUserSecretKey)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to gen token:" + err.Error(),
		})
		return
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "登陆成功",
		"token":   token,
		"email":   data.Email,
	})
}

// 获取头像路由
func GetHead(ctx *gin.Context) {
	//返回头像
	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to get head",
		"head":    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
	})
}

// 实现切换头像路由
func ChangeHead(ctx *gin.Context) {
	var data admin.ChangeHeadRequest
	err := ctx.ShouldBindJSON(&data)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to bind args:" + err.Error(),
		})
		return
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to change head",
	})
}

// 实现获取今日信息
func GetTodayInfo(ctx *gin.Context) {
	data := admin.GetTodayInfoResponse{
		TotalBrowses: 23234,
		TotalOrders:  100,
		AddNewGoods:  100,
	}

	//返回今日信息
	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to get today info",
		"data":    data,
	})
}

// 实现获取今日商品排行
func GetTodayGoods(ctx *gin.Context) {
	data := []admin.GetTodayGoodsResponse{
		{
			Name:     "MacBook 17",
			Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier: "2476358005@qq.com",
			Sales:    100,
			Total:    "3435.1",
		}, {
			Name:     "MacBook 14",
			Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier: "2476358005@qq.com",
			Sales:    200,
			Total:    "3435.1",
		},
	}

	//返回今日商品排行
	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to get today goods",
		"data":    data,
	})
}

// 实现获取商品列表
func GetGoodsList(ctx *gin.Context) {
	data := []admin.GetGoodsList{
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "0",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "0",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "0",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "0",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "0",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "0",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBoaddsaok 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "asddasasdad@qq.com",
			Status:    "0",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBoaddsaok 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "asddasasdad@qq.com",
			Status:    "1",
			Checked:   false,
		},
	}

	//返回今日商品排行
	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to get today goods",
		"data":    data,
	})
}

// 实现商品搜索
func SearchGoods(ctx *gin.Context) {
	var request admin.SearchGoodsRequest
	//获取搜索关键字
	ctx.ShouldBindJSON(&request)
	//请实例化商品

	//获取到搜索关键词
	data := []admin.GetGoodsList{
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": request.Keyword,
		"data":    data,
	})
}

// 实现获取商品详情页
func GetGoodsDetail(ctx *gin.Context) {
	var request admin.GetGoodsDetailRequest
	ctx.ShouldBindJSON(&request)
	//获取商品详情

	data := admin.GetGoodsDetailResponse{
		GoodsId: request.GoodsId,
		Desc:    "this is MacBook 13",
		Pic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		Name:    "MacBook 13",
		Price:   "9999.9",
		Unit:    "台",
		Stock:   100,
		Status:  0,
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to get goods details",
		"data":    data,
	})
}

// 实现修改商品状态
func ChangeGoodsStatus(ctx *gin.Context) {
	var request admin.ChangeGoodsStatusRequest
	err := ctx.ShouldBindJSON(&request)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to bing request data:" + err.Error(),
		})
		return
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    request.Status,
		"message": request.GoodsId,
	})

}

// 获取待审核的商品
func GetPendingGoods(ctx *gin.Context) {
	data := []admin.GetGoodsList{
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "0",
			Checked:   false,
		},
		{
			GoodsId:   "63e43345",
			GoodsName: "MacBook 17",
			GoodsPic:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Supplier:  "2476358005@qq.com",
			Status:    "1",
			Checked:   false,
		},
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success get pending goods",
		"data":    data,
	})
}

// 获取所有订单信息
func GetOrderList(ctx *gin.Context) {
	//实例化订单列表
	data := []admin.GetOrderListResponse{
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to get order list",
		"data":    data,
	})
}

// 通过订单ID获取订单信息
func GetOrderByID(ctx *gin.Context) {
	var request admin.GetOrderByIDRequest

	data := admin.GetOrderListResponse{
		OrderId:     "1234567890",
		SupplierId:  "tasklsr",
		Supplier:    "golandcxy@gmail.com",
		SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		User:        "golandlsr@gmail.com",
		UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		TotalMoney:  "99992.2",
		Status:      0,
		Checked:     false,
	}

	err := ctx.ShouldBindJSON(&request)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "success to get id",
		})
		return
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    request.OrderId,
		"message": "success to get id",
		"data":    data,
	})
}

// 通过订单ID获取订单详情
func GetOrderDetailByID(ctx *gin.Context) {
	var request admin.GetOrderByIDRequest

	err := ctx.ShouldBindJSON(&request)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to get order detail",
		})
		return
	}

	data := admin.Order{
		Id:          "123342",
		Supplier:    "2476358005@qq.com",
		User:        "golandcxy@gmail.com",
		Amount:      "99992.2",
		Status:      2,
		CreateTime:  time.Now().Format("2006-01-02 15:04:05"),
		Invoice:     "",
		Logistics:   "",
		LogisticsId: "",
		Receipt:     "",
		ReceiptInfo: admin.UserAddress{
			Name:        "李硕荣",
			PhoneNumber: "13079071086",
			Address:     "湖南省长沙市湖南科技职业学院",
		},
		GoodsInfo: []admin.Good{
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Price:    "2003",
				Stock:    2,
				Status:   0,
			},
		},
	}
	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": request.OrderId,
		"data":    data,
	})
}

// 获取所有商家列表
func GetSupplierList(ctx *gin.Context) {
	data := []admin.SupplierUser{
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
		{
			Email: "golandcxy@gmail.com",
			Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		},
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to get supplier list",
		"data":    data,
	})
}

// 通过商家ID实现获取商家的商品信息
func GetSupplierByID(ctx *gin.Context) {
	var request admin.SearchSupplierIDRequest

	err := ctx.ShouldBindJSON(&request)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to bind data:" + err.Error(),
		})
		return
	}

	data := admin.SupplierUser{
		Email: request.SupplierId,
		Head:  "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		Goods: []admin.Good{
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   1,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   1,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   1,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   0,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   1,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   0,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   1,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   1,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   0,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   1,
			},
			{
				Id:       "63e43345",
				Name:     "MacBook 17",
				Pic:      "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
				Supplier: "2476358005@qq.com",
				Status:   1,
			},
		},
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to get supplier info",
		"data":    data,
	})
}

// 通过商家ID获取商家订单信息
func GetSupplierOrder(ctx *gin.Context) {
	var request admin.SearchSupplierIDRequest

	err := ctx.ShouldBindJSON(&request)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to bind data:" + err.Error(),
		})
		return
	}

	data := []admin.GetOrderListResponse{
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
		{
			OrderId:     "1234567890",
			SupplierId:  "tasklsr",
			Supplier:    "golandcxy@gmail.com",
			SupplierPic: "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			User:        "golandlsr@gmail.com",
			UserPic:     "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			TotalMoney:  "99992.2",
			Status:      0,
			Checked:     false,
		},
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": request.SupplierId,
		"data":    data,
	})
}

// 获取用户列表
func GetUserList(ctx *gin.Context) {
	data := []admin.GetUserListResponse{
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
		{
			Id:     "12435",
			Email:  "golandcxy@gmail.com",
			Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
			Status: 1,
		},
	}
	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success get user",
		"data":    data,
	})
}

// 实现通过邮箱搜索用户
func SearchUser(ctx *gin.Context) {
	var request admin.SearchUserRequest

	err := ctx.ShouldBindJSON(&request)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to bind data" + err.Error(),
		})
		return
	}

	data := admin.GetUserListResponse{
		Id:     "12435",
		Email:  "golandcxy@gmail.com",
		Pic:    "https://daisyui.com/images/stock/photo-1534528741775-53994a69daeb.jpg",
		Status: 1,
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success to get data",
		"data":    data,
	})
}

// 实现修改用户状态
func ChangeUserStatus(ctx *gin.Context) {
	var request admin.ChangeUserStatusRequest

	err := ctx.ShouldBindJSON(&request)
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    500,
			"message": "failed to bind data" + err.Error(),
		})
		return
	}

	ctx.JSON(http.StatusOK, gin.H{
		"code":    request.Status,
		"message": request.Email,
	})
}
